# 1、有这样的一个列表，深度不可知，列表里面还会嵌套列表，我想要把这个列表从左到右拼接成一个新的列表，且顺序不变
# 举例：[12,33,[11,22,33,[55,66,99]],[55,66]]
# 变成：[12, 33, 11, 22, 33, 55, 66, 99, 55, 66]

from datetime import datetime


# def fors(lists):
#
#     list2 = list()
#     for x in lists:
#         if type(x) != list:
#             list2.append(x)
#         else:
#             for y in x:
#                 if type(y) != list:
#                     list2.append(y)
#                 else:
#                     for z in y:
#                         list2.append(z)
#     return list2

# def flatten_list(lst):
#     result = []
#     for item in lst:
#         if isinstance(item, (list, tuple)):  # 检查元素是否为列表或元组
#             result.extend(flatten_list(item))  # 如果是，递归调用flatten_list
#         else:
#             result.append(item)  # 如果不是，直接添加到结果列表中
#     return result
#
# s = [12, 33, [11, 22, 33, [55, 66, 99]], [55, 66]]
# print(flatten_list(s))

# 2、编写装饰器，为多个函数加上认证的功能（用户的账号密码）
#  要求登录成功一次，后续的函数都无需输入用户名和密码

# denglyanzheng = 0
#
# def decorate(func):
#     def authentication():
#         user = "123"
#         pwd = "123456"
#         c = 0
#         while True:
#             a, b = func()
#             if user != a or pwd != b:
#                 print("账号密码错误")
#                 c += 1
#                 if c >= 3:
#                     print('已错误三次，请稍后输入')
#                     break
#             else:
#                 print("登录成功")
#                 global dengluyanzheng  # 声明，用的是全局变量dengluyanzheng
#                 dengluyanzheng = 1
#                 break
#
#     return authentication
#
#
# @decorate
# def login():
#     a = input("账号: ")
#     b = input("密码: ")
#     return a, b
#
#
# def lsajkfhas():
#     print("=====================================================")
#     if dengluyanzheng == 1:
#         print("免登录")
#     else:
#         login()
#
#
# login()
# lsajkfhas()

# denglyanzheng = 0
#
# def decorate(func):
#     def authentication():
#         user = "root"
#         pwd = "123456"
#         a, b = func()
#         if user == a and pwd == b:
#             print("登录成功")
#
#         else:
#             print("账号密码错误")
#
#     return authentication
#
#
# @decorate
# def login():
#     if denglyanzheng == 0:
#         a = input("账号:")
#         b = input("密码:")
#     else:
#         print("验证成功，直接登录")
#     return a, b
#
#
# login()

# 3、请实现一个装饰器，把函数的返回值+100然后返回

# 装饰器：固定格式
# def jia100(ss):
#     def date():
#         s = ss()
#         return int(s) + 100
#     # 返回 date() 函数
#     return date
#
#
# @jia100
# def xixi():
#     a = 5
#     return a
#
#
# print(xixi())

# 4、请实现一个装饰器，通过一次调用使函数重复执行5次

# def zhuangshiqi(hanshu):
#     def bianli():
#         for i in range(5):
#             hanshu()
#     return bianli
#
#
# @zhuangshiqi
# def hanshu():
#     print(121)

# 5、输入任意个字符串,分别实现从小到大输出和从大到小输出

# 6、接收n个数字，求这些参数数字的和
b = 0
# def zhuangshiqi(hanshu):
#     a  = 0
#     # 如果是多个变量，传参时候需要保持一致
#     def bianli(*s):
#         s = hanshu(*s)
#         return sum(s)
#     return bianli
#
#
# @zhuangshiqi
# # 如果是多个变量，传参时候需要保持一致
# def hanshu(*s):
#     return s
#
# print(hanshu(1,2,30,5))

# 7、编写一个函数，实现数字的自增（从0开始，每调用一次，数字+1）
